#include <iostream>
#include <sstream>

using namespace std;

const int N = 200;

string s[N];
string s1, s2;
string res;

int main()
{
	string line;
	
	getline(cin, line);
	
	stringstream ssin(line);
	
	string node;
	
	int t = 0;
	
	while (ssin >> node)
	{
		s[t ++ ] = node;
	}
	
	cin >> s1 >> s2;
	
	
	for (int i = 0; i < t; i ++ )
	{
		if (s[i] == s1) res += s2;
		else res += s[i];
		
		res += ' ';
	}
	
	cout << res << endl;
	
	return 0;
	
}
